﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MovingChameLibrary.Models
{
    public sealed class Filter<T> : BindableBase
    {
        private String _name;
        private List<T> _results;
        private bool _active;

        public Filter(String name, IEnumerable<T> results, bool active = false)
        {
            this.Name = name;
            this.Results = results.ToList();
            this.Active = active;
        }

        public int Count { get { return _results.Count; } }

        public override String ToString()
        {
            return Description;
        }

        public String Name
        {
            get { return _name; }
            set { if (this.SetProperty(ref _name, value)) this.OnPropertyChanged("Description"); }
        }

        public List<T> Results
        {
            get { return _results; }
            set { if (this.SetProperty(ref _results, value)) this.OnPropertyChanged("Description"); }
        }

        public bool Active
        {
            get { return _active; }
            set { this.SetProperty(ref _active, value); }
        }

        public String Description
        {
            get { return String.Format("{0} ({1})", _name, Count); }
        }
    }
}